/*
 * AnalyzeCharges.h
 *
 *  Created on: May 26, 2011
 *      Author: marchi
 */

#ifndef ANALYZECHARGES_H_
#define ANALYZECHARGES_H_

#include "Metric.h"
#include "RhoAverage.h"
#include <cstdlib>
#include <cstdio>
#include "time.h"
#include "pdbio.h"
#include "confio.h"
#include "CellSymmetry.h"
#include "Grid_SpecTemplates.hpp"

//enum ElecType {Slt, Sol, Tot};

static Rho * ro=NULL;
static int nframes=0;
static int mycounter=0;
static CellSymmetry * symmetry=NULL;

static int Analyze(t_topology *top, t_trxframe *fr, t_pbc *pbc,
              int nr, gmx_ana_selection_t *sel[], void *data)
{
    /* Here, you can do whatever analysis your program requires for a frame. */
	Averages * Avgs=static_cast<Averages *> (data);

	RhoAverage ** roavg0=Avgs->Ro;
    RhoAverage * & roavg=*roavg0;

    mycounter++;
    srand (time(NULL) );

    Grid<1>::set(fr->box);
	Grid<DIM>::set(fr->box);


    if(!symmetry) symmetry=new CellSymmetry(top,fr,pbc);

    Metric Met;
    Met(fr->box);
    symmetry->Center();

    chg[Sol].setCoord(Met,fr->x,cidx[Sol]);
    chg[Slt].setCoord(Met,fr->x,cidx[Slt]);

    *atPDB+=chg[Slt];
    roavg[Sol].Density(chg[Sol]);

    nframes++;
    return 0;
}

#endif /* ANALYZECHARGES_H_ */
